class Item {

    attack: number = 0;

    name = "";

    description:string="";

    y = 0;

    x = 0;
    mapId = 0;
    id=0;
    specialskill=0;
    avatarx=0;
    avatary=0;
    itemImage = new Image();
    itemAvatarImage=new Image();
    ClickIndex=0;



   
    view = new renderer.Bitmap(0, 0, this.itemImage);

    parseFromConfig(config: any) {
        this.attack = config.attack;
        this.name = config.name;
        this.x = config.x;
        this.y = config.y;
        this.mapId = config.mapId;
        this.itemImage.src = config.image;
        this.itemAvatarImage.src=config.avatar;
        this.avatarx=config.avatarX;
        this.avatary=config.avatarY;
        this.description=config.description;
        this.ClickIndex=config.clickIndex;
        this.id=config.id;
        this.specialskill=config.specialskill;
        
    }

    toString() {
        return `[Item: name:${this.name} attack:${this.attack}]`
    }
}
class ItemManager extends EventDispatcher{
    
    Items: Item[] = [];

    constructor() {
        super();
    }

    
    parseFromConfig(config:any) {
        for (let item of config.item) {
            const item1 = new Item();
            item1.parseFromConfig(item);
            itemManager.Items.push(item1);
        }
        
    }
}
const itemManager = new ItemManager();